<include file="Public:header"/>
<div class="cat">
<table border="1" bordercolor="#DDDFFF" width="100%" style="border-collapse: collapse" cellpadding="5">
	<tr>
		<td align="right">上级分类：</td>
		<td>
		<select size="1" name="parent">

	       <option value="0">顶级分类</option>

<volist name="cat_list" id="cat_list">
<if condition="$cat_list.cat_id eq $pid">
	      <option value="{$cat_list.cat_id}" selected>{$cat_list.fullname}</option>
<else/>
         <option value="{$cat_list.cat_id}">{$cat_list.fullname}</option>
</if>
</volist>
	    </select>　
		</td>
	</tr>
	<tr>
		<td align="right">所属模型：</td>
		<td><select size="1" name="model">
<volist name="model" id="model">
<if condition="$model.model_id eq $mid">
	       <option value="{$model.model_id}" selected>{$model.model_name}</option>
<else/>
          <option value="{$model.model_id}">{$model.model_name}</option>
</if>
</volist>
        </select>
		</td>
	</tr>
	<tr>
		<td align="right">分类名称：</td>
		<td><input type="text" name="cat_name" ></td>
	</tr>
	<tr>
		<td align="right">SEO关键词：</td>
		<td><textarea rows="2" name="seo" cols="40"></textarea></td>
	</tr>
	<tr>
		<td align="right">是否显示：</td>
		<td><select name="is_show">
				<option value="0">显示</option>
				<option value="1">不显示</option>
			  </select>
	    </td>
	</tr>
	<tr>
		<td align="right">是否推荐：</td>
		<td><select name="is_hot">
				<option value="0">不推荐</option>
				<option value="1">推荐</option>
			  </select>
	    </td>
	</tr>
	<tr>
		<td align="right">分类图标：</td>
		<td><input type="text" name="icon">图标放到/statics/icons/cate目录下</td>
	</tr>
</table>
</div>
<input name="cat_id" type="text" style="display:none" value="{$cat.cat_id}">
<div id="save"><input id="change" type="button" value="添加分类"></div>


<script>
$(function(){
    $("#change").click(function(){
	    var parent=$("[name=parent]").val();
		var model=$("[name=model]").val();
		var name=$("[name=cat_name]").val();
		var seo=$("[name=seo]").val();
		var is_show=$("[name=is_show]").val();
		var icon=$("[name=icon]").val();
		var is_hot=$("[name=is_hot]").val();

         $.ajax({
		     type:"POST",
			 url:"__URL__/add_cat",
			 dataType:"json",
			 data:{'parent':parent,'model':model,'name':name,'seo':seo,'is_show':is_show,'icon':icon,'is_hot':is_hot},
			 success:function(data){
			     if(data=='1'){
				   jSuccess("<strong>修改成功!</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
				 }else{
				   jError("<strong>修改失败！请重试</strong>",{VerticalPosition : 'center',HorizontalPosition : 'center'});
				 }
			 }
		 })
	})

})
</script>
</body>
</html>